#include<iostream>
#include<algorithm>
using namespace std;
struct student
{
	int ai;
	double bi;
};
struct student s[1005];
bool cmp(struct student a,struct student b)
{
	if( a.bi==b.bi )
		return a.ai<b.ai;
	return a.bi<b.bi;
}
int main()
{
	int n,i;
	scanf("%d",&n);getchar();
	for(i=0;i<n;i++)
		scanf("%d %lf",&s[i].ai,&s[i].bi);
	sort(s,s+n,cmp);
	for(i=0;i<n;i++)
		printf("%d %.3lf\n",s[i].ai,s[i].bi);
	return 0;
}

